// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   RTO_PQImpl.java

package com.sunwayhorizo.health.hl7.datatypes.common;

import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.datatypes.ANY;
import com.sunwayhorizo.health.hl7.datatypes.BL;
import com.sunwayhorizo.health.hl7.datatypes.CS;
import com.sunwayhorizo.health.hl7.datatypes.PQ;
import com.sunwayhorizo.health.hl7.datatypes.QTY;
import com.sunwayhorizo.health.hl7.datatypes.RTO_PQ;
import com.sunwayhorizo.health.hl7.datatypes.ST;
import com.sunwayhorizo.health.hl7.datatypes.TYPE;


// Referenced classes of package oracle.apps.ctb.hl7.types.common:
//            ANYImpl, BLImpl, CSImpl, NullFlavorImpl, 
//            PQImpl, REALImpl, STImpl, TYPEImpl

public class RTO_PQImpl extends ANYImpl
    implements RTO_PQ
{

    public static final String RCS_ID = "$Header: RTO_PQImpl.java 115.27.2050.2 2005/12/23 07:05:29 mmoores noship $";
    public static final String SEPARATOR = ":";
    public static final String UNO = "1";
    private PQ mNumerator;
    private PQ mDenominator;
    private static final RTO_PQ nullNI = new RTO_PQImpl(CSImpl.valueOf("NI"));
    private static final RTO_PQ nullOTH = new RTO_PQImpl(CSImpl.valueOf("OTH"));
    private static final RTO_PQ nullNINF = new RTO_PQImpl(CSImpl.valueOf("NINF"));
    private static final RTO_PQ nullPINF = new RTO_PQImpl(CSImpl.valueOf("PINF"));
    private static final RTO_PQ nullUNK = new RTO_PQImpl(CSImpl.valueOf("UNK"));
    private static final RTO_PQ nullASKU = new RTO_PQImpl(CSImpl.valueOf("ASKU"));
    private static final RTO_PQ nullNAV = new RTO_PQImpl(CSImpl.valueOf("NAV"));
    private static final RTO_PQ nullMSK = new RTO_PQImpl(CSImpl.valueOf("MSK"));
    private static final RTO_PQ nullNA = new RTO_PQImpl(CSImpl.valueOf("NA"));
    private static final RTO_PQ nullNASK = new RTO_PQImpl(CSImpl.valueOf("NASK"));

    protected RTO_PQImpl(PQ pq, PQ pq1)
    {
        if(pq == null || pq.isNull().isTrue())
            mNumerator = PQImpl.valueOf(REALImpl.valueOf("1"), CSImpl.valueOf("1"));
        else
            mNumerator = pq;
        if(pq1 == null || pq1.isNull().isTrue())
            mDenominator = PQImpl.valueOf(REALImpl.valueOf("1"), CSImpl.valueOf("1"));
        else
            mDenominator = pq1;
//        if(mDenominator.value().equal(REALImpl.valueOf("0")).isTrue())
//            throw ANYImpl.newRatioException("RTO<PQ>");
//        else
//            return;
    }

    protected RTO_PQImpl()
    {
        mNumerator = PQImpl.valueOf(REALImpl.valueOf("1"), CSImpl.valueOf("1"));
        mDenominator = PQImpl.valueOf(REALImpl.valueOf("1"), CSImpl.valueOf("1"));
    }

    protected RTO_PQImpl(CS cs)
    {
        super(true, cs);
        mNumerator = PQImpl.nullPQ(NullFlavorImpl.NI);
        mDenominator = PQImpl.nullPQ(NullFlavorImpl.NI);
    }

    public static RTO_PQ valueOf(PQ pq, PQ pq1)
    {
        return new RTO_PQImpl(pq, pq1);
    }

    public static RTO_PQ valueOf()
    {
        return new RTO_PQImpl();
    }

    public static RTO_PQ nullRTO_PQ()
    {
        return new RTO_PQImpl(null);
    }

    public BL equal(ANY any)
    {
        if(!(any instanceof RTO_PQ))
            return BLImpl.FALSE;
        if(isNull().or(any.isNull()).isTrue())
        {
            return BLImpl.FALSE;
        } else
        {
            RTO_PQ rto_pq = (RTO_PQ)any;
            return mNumerator.equal(rto_pq.numerator()).or(mNumerator.isNull().and(rto_pq.numerator().isNull())).and(mDenominator.equal(rto_pq.denominator()).or(mDenominator.isNull().and(rto_pq.denominator().isNull())));
        }
    }

    public TYPE dataType()
    {
        return com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.RTO_PQ;
    }

    public BL lessOrEqual(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("RTO<PQ>", "lessOrEqual");
    }

    public BL compares(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("RTO<PQ>", "compares");
    }

    public TYPE diffType()
    {
        return com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.RTO_PQ;
    }

    public QTY minus(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("RTO<PQ>", "minus");
    }

    public QTY plus(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("RTO<PQ>", "plus");
    }

    public BL isZero()
    {
        throw ANYImpl.newUnsupportedException("RTO<PQ>", "isZero");
    }

    public BL lessThan(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("RTO<PQ>", "lessThan");
    }

    public BL greaterOrEqual(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("RTO<PQ>", "greaterOrEqual");
    }

    public BL greaterThan(QTY qty)
    {
        throw ANYImpl.newUnsupportedException("RTO<PQ>", "greaterThan");
    }

    public ST literal()
    {
        StringBuffer stringbuffer = new StringBuffer();
        if(mNumerator.isNull().isTrue())
            stringbuffer.append("1");
        else
            stringbuffer.append(mNumerator.literal().stringValue());
        if(mDenominator.isNull().isFalse())
        {
            stringbuffer.append(":");
            stringbuffer.append(mDenominator.literal().stringValue());
        }
        return STImpl.valueOf(stringbuffer.toString());
    }

    public PQ numerator()
    {
        return mNumerator;
    }

    public PQ denominator()
    {
        return mDenominator;
    }

    public int hashCode()
    {
        int i = 17;
        if(isNull().isFalse())
        {
            i = 37 * i + numerator().hashCode();
            i = 37 * i + denominator().hashCode();
        }
        return i;
    }

//    public XMLNode[] writeXML(XMLDocument xmldocument, String s)
//        throws Hl7Exception
//    {
//        try
//        {
//            XMLElement xmlelement = (XMLElement)xmldocument.createElement(s);
//            if(numerator() != null && numerator().isNull().isFalse())
//                xmlelement.appendChild(((PQImpl)numerator()).writeXML(xmldocument, "numerator")[0]);
//            if(denominator() != null && denominator().isNull().isFalse())
//                xmlelement.appendChild(((PQImpl)denominator()).writeXML(xmldocument, "denominator")[0]);
//            return (new XMLNode[] {
//                xmlelement
//            });
//        }
//        catch(Exception exception)
//        {
//            throw new Hl7Exception(exception);
//        }
//    }

    public static RTO_PQ nullRTO_PQ(CS cs)
    {
        String s = null;
        if(cs == null || cs.literal().stringValue() == null || cs.isNull().isTrue())
            s = "NI";
        else
            s = cs.literal().stringValue();
        if(s.equals("NI"))
            return nullNI;
        if(s.equals("OTH"))
            return nullOTH;
        if(s.equals("NINF"))
            return nullNINF;
        if(s.equals("PINF"))
            return nullPINF;
        if(s.equals("UNK"))
            return nullUNK;
        if(s.equals("ASKU"))
            return nullASKU;
        if(s.equals("NAV"))
            return nullNAV;
        if(s.equals("MSK"))
            return nullMSK;
        if(s.equals("NA"))
            return nullNA;
        if(s.equals("NASK"))
            return nullNASK;
        else
            return nullNI;
    }

}
